Scientific graph

Now we make an example of presentation of scientific results. Imagine that we have measured vapour pressures of some chemical species and afterwards we have found the best fit in the form

log p = A - $\displaystyle {\frac{{B}}{{t+C}}}$ (1)

where t is temperature in degrees Centigrade and p is pressure in kilopascals. Numerical values of parameters A, B, C are defined later in the {\logo META}{\logo FONT} source.

As you can see, the temperature ranges from 60 oC to 90 oC and pressure ranges from 80 kPa to 170 kPa. We therefore need some scaling and shift of the origin. A novice might read about currenttransform and try to harness it. This, however, has undesirable side-effects and therefore we suggest to avoid it. It is better to use simple linear transform defined with macros.
\begin{mfcode}
def degC = degCa + degCb enddef;
def kPa = kPaa + kPab enddef;
\end{mfcode}

Now let's examine what happens if we write 75degC. This expression expands to 75degCa + degCb. It's clear how the transform works. We must only emphasize that 75degC is not equal to degC*75 because degC is not a variable but a macro.

Now we can start the plot. We specify the dimensions of the character, define the temperature–pressure coordinates of the lower left and upper right corners ({\logo META}{\logo FONT} evaluates degCa, degCb, kPaa, kPab for us) and specify parameters A, B, C and seven experimental points.

You will see special variables w and h. At the time of reading beginchar {\logo META}{\logo FONT} assigns width to w, height to h and depth to d. All these variables are expressed in pixels rounded to whole numbers.
\begin{mfcode}
beginchar(''B'',100u ...
It is tedious to type this by hand but it can be prepared by the program which is used for finding the best fit.

In this case the best fit was expressed in a way which can be evaluated with {\logo META}{\logo FONT}. This is not a frequent situation. The easiest way is to tabulate the best fit in many points (do it with your software and make the output suitable for input to {\logo META}{\logo FONT}) and connect them with a crooked line. You will use a similar technique as below. The only difference is that you will define the points but we are calculating them. It is of course possible to draw a curve which is not mathematically defined as the best fit. In such a case you should specify a very small number of points and play with directions and tensions. The next part shows that the index expression may even be a real number.


\begin{mfcode}
for t := 55 step .3 until 95:
x[t] = t*degC;
y[t] = (mexp(A - ...
... 1.5pt;
draw z55 for t:= (55+.3) step .3 until 95: --z[t] endfor;
\end{mfcode}

{\logo META}{\logo FONT} has some limitation for calculations. Value 4096 is treated as infinity. Greater values can appear in calculations but they must be less that 32768. Therefore, the values B = 605000 would cause arithmetic overflow. Due to it we had to modify equation [*].

We have seen another useful feature of {\logo META}{\logo FONT}. The loop command may even be used in the middle of expression. Here it was used inside the draw command.

We also want to see the experimental points. We will draw them as squares.


\begin{mfcode}
pickup pensquare scaled 4u;
for k:= 1 upto 7: drawdot z[k]; endfor;
\end{mfcode}

At last we draw the frame with marks for 75 oC, 100 kPa, and 150 kPa.
\begin{mfcode}
pickup pensquare scaled .7pt;
draw origin--(0,h)--(w,h)--(w,0)-...
... (0,100kPa)--(5u,100kPa);
draw (0,150kPa)--(5u,150kPa);
endchar;
\end{mfcode}

Notice that we specified the position of marks in the corresponding units. We could as well use w/2 or even 50u instead of 75degC. Such things are, however, too absolute. If you for some reason change the with to 150u`#12#, 50u will no longer correspond to 75 oC. You can change the temperature range to 60 oC–120 oC and now w/2 corresponds to 90 oC. It is clear that 75degC is invariate under such changes.

Figure: Vapour pressure curve
\begin{figure}\setlength{\unitlength}{1truemm}%
\providecommand{\x}{-5}%
\pro...
...}$C]}}
\put(-30,90){\makebox(20,4)[br]{p\,[kPa]}}
\end{picture}
\end{figure}

Look how figure [*] has been done. It might look horrible but after some practice you will find it easy.

{\logo META}{\logo FONT} has more advanced mechanisms which could be harnessed for transfer of dimensions and coordinates. Some macro packages as incpic.mf and incpic.tex by Oldřich Ulrych make use of it. But this is for experts (or those who do not care how it works inside). A novice would have hard times to understand it. If you know the mechanism, you cam find your own bugs and you can modify it so that it satisfies your personal needs.

The easiest way seems to be the standard LATEX' picture environment. To avoid some calculations, we place the origin of the environment into the origin of our graph. All texts are aligned using \makebox commands. The dimensions are specified in truemm and truecm. These units remain the same if you change the \magnification. It cannot be done in LATEX but it is used here in case someone would like to incorporate similar concepts into plain TEX.